package com.codi.bus.core.service.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.codi.base.util.DateUtils;
import com.codi.base.util.MoneyUtils;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 基金资产
 *
 * @author Shangdu Lin
 */
public class AssetFundModel {


    /**
     * 是否有在途
     */
    private boolean inTransit;

    public boolean getInTransit() {
        return this.inTransit;
    }

    public void setInTransit(boolean inTransit) {
        this.inTransit = inTransit;
    }

    /**
     * 在途金额
     */
    private BigDecimal inTransitAmount;

    public BigDecimal getInTransitAmount() {
        return inTransitAmount;
    }

    public void setInTransitAmount(BigDecimal inTransitAmount) {
        this.inTransitAmount = inTransitAmount;
    }

    /**
     * 在途中笔数
     */
    private Integer inTransitNum;

    public Integer getInTransitNum() {
        return inTransitNum;
    }

    public void setInTransitNum(Integer inTransitNum) {
        this.inTransitNum = inTransitNum;
    }

    public String getInTransitNumString() {
        if (inTransitNum != null && inTransitNum != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("有");
            sb.append(inTransitNum);
            sb.append("笔买入确认中");
            return sb.toString();
        }
        return "";
    }

    /**
     * 净值日期
     */
    private Date netValueDate;

    public Date getNetValueDate() {
        return this.netValueDate;
    }

    public void setNetValueDate(Date netValueDate) {
        this.netValueDate = netValueDate;
    }

    // 净值日期字符串 MM-dd
    public String getNetValueDateString() {
        if (this.netValueDate != null) {
            return DateUtils.formatDate7(this.netValueDate);
        } else {
            return "";
        }
    }

    /**
     * 当日收益
     */
    private BigDecimal totalTodayIncome;

    public BigDecimal getTotalTodayIncome() {
        return this.totalTodayIncome;
    }

    public void setTotalTodayIncome(BigDecimal totalTodayIncome) {
        this.totalTodayIncome = totalTodayIncome;
    }

    /**
     * 当日收益 用作记录  只有T0基金有
     */
    private BigDecimal totalTodayIncomeRecord;

    public BigDecimal getTotalTodayIncomeRecord() {
        return this.totalTodayIncomeRecord;
    }

    public void setTotalTodayIncomeRecord(BigDecimal totalTodayIncomeRecord) {
        this.totalTodayIncomeRecord = totalTodayIncomeRecord;
    }

    public String getTotalTodayIncomeString() {
        return MoneyUtils.formatMoney(this.totalTodayIncome, 2);
    }

    /**
     * 总资产
     */
    private BigDecimal totalWorthValue;

    public BigDecimal getTotalWorthValue() {
        return this.totalWorthValue;
    }

    public void setTotalWorthValue(BigDecimal totalWorthValue) {
        this.totalWorthValue = totalWorthValue;
    }

    public String getTotalWorthValueString() {
        return MoneyUtils.formatMoney(this.totalWorthValue, 2);
    }

    /**
     * 基金个数
     */
    private Integer fundsCount;

    public Integer getFundsCount() {
        return this.fundsCount;
    }

    public void setFundsCount(Integer fundsCount) {
        this.fundsCount = fundsCount;
    }

    /**
     * 当日净值
     */
    private BigDecimal netValue;

    public BigDecimal getNetValue() {
        return this.netValue;
    }

    public void setNetValue(BigDecimal netValue) {
        this.netValue = netValue;
    }

    /**
     * 上一工作日净值
     */
    private BigDecimal lastNetValue;

    public BigDecimal getLastNetValue() {
        return this.lastNetValue;
    }

    public void setLastNetValue(BigDecimal lastNetValue) {
        this.lastNetValue = lastNetValue;
    }

    /**
     * 货币基金的万份收益
     */
    private BigDecimal dailyProfit;

    public BigDecimal getDailyProfit() {
        return this.dailyProfit;
    }

    public void setDailyProfit(BigDecimal dailyProfit) {
        this.dailyProfit = dailyProfit;
    }

    /**
     * 非货币基金的日收益率
     */
    private BigDecimal todayIncomeRate;

    public BigDecimal getTodayIncomeRate() {
        return this.todayIncomeRate;
    }

    public void setTodayIncomeRate(BigDecimal todayIncomeRate) {
        this.todayIncomeRate = todayIncomeRate;
    }

    /**
     * 是否是货币基金
     */
    @JSONField(serialize = false)
    private boolean isCurrency;

    public boolean getIsCurrency() {
        return this.isCurrency;
    }

    public void setIsCurrency(boolean isCurrency) {
        this.isCurrency = isCurrency;
    }

    /**
     * 当前份额
     */
    private BigDecimal currentShares;

    private BigDecimal enableShares;

    public BigDecimal getEnableShares() {
        return enableShares;
    }

    public void setEnableShares(BigDecimal enableShares) {
        this.enableShares = enableShares;
    }

    public BigDecimal getCurrentShares() {
        return this.currentShares;
    }

    public void setCurrentShares(BigDecimal currentShares) {
        this.currentShares = currentShares;
    }

    /**
     * 当前份额减去T确认的T-1申购的不算T-1日收益的份额
     */
    private BigDecimal currentSharesWithoutTodayConfirmed;

    public BigDecimal getCurrentSharesWithoutTodayConfirmed() {
        return this.currentSharesWithoutTodayConfirmed;
    }

    public void setCurrentSharesWithoutTodayConfirmed(BigDecimal currentSharesWithoutTodayConfirmed) {
        this.currentSharesWithoutTodayConfirmed = currentSharesWithoutTodayConfirmed;
    }


    /**
     * 资产类型
     */
    private int assetType;

    public int getAssetType() {
        return this.assetType;
    }

    public void setAssetType(int assetType) {
        this.assetType = assetType;
    }

    private String fundCode;

    @JSONField(serialize = false)
    public String getFundCode() {
        return this.fundCode;
    }

    public String getFCode() {
        return this.fundCode;
    }

    public void setFundCode(String fundCode) {
        this.fundCode = fundCode;
    }

    private String fundName;

    public String getFundName() {
        return fundName;
    }

    public void setFundName(String fundName) {
        this.fundName = fundName;
    }

    @JSONField(serialize = false)
    private BigDecimal accumIncome;

    public BigDecimal getAccumIncome() {
        return accumIncome;
    }

    public void setAccumIncome(BigDecimal accumIncome) {
        this.accumIncome = accumIncome;
    }

    private BigDecimal totalAccumIncome;

    public BigDecimal getTotalAccumIncome() {
        return totalAccumIncome;
    }

    public void setTotalAccumIncome(BigDecimal totalAccumIncome) {
        this.totalAccumIncome = totalAccumIncome;
    }

    public String getTotalAccumIncomeString() {
        String back = MoneyUtils.formatMoney(this.totalAccumIncome, 2);
        return back == null ? "0.00" : back;
    }

    private BigDecimal unpaidIncome;

    public BigDecimal getUnpaidIncome() {
        return unpaidIncome;
    }

    public void setUnpaidIncome(BigDecimal unpaidIncome) {
        this.unpaidIncome = unpaidIncome;
    }

    private BigDecimal totalUnpaidIncome;

    public BigDecimal getTotalUnpaidIncome() {
        return totalUnpaidIncome;
    }

    public void setTotalUnpaidIncome(BigDecimal totalUnpaidIncome) {
        this.totalUnpaidIncome = totalUnpaidIncome;
    }

    //持有基金列表
    private List<AssetFundModel> fundModelList;

    public List<AssetFundModel> getFundModelList() {
        return fundModelList;
    }

    public void setFundModelList(List<AssetFundModel> fundModelList) {
        this.fundModelList = fundModelList;
    }

    //占据组合比例
    private BigDecimal investRate;

    public BigDecimal getInvestRate(){ return investRate; }

    public void setInvestRate(BigDecimal investRate){ this.investRate = investRate; }

    //交易账号
    @Getter
    @Setter
    private String tradeAcco;

    //持仓收益
    @Getter
    @Setter
    private BigDecimal shareIncome;

    //成本
    @Getter
    @Setter
    private BigDecimal cost;

    @Getter
    @Setter
    private Integer sellInTransit;

    public String getSellInTransitString() {
        if (sellInTransit != null && sellInTransit != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("有");
            sb.append(sellInTransit);
            sb.append("笔赎回确认中");
            return sb.toString();
        }
        return "";
    }

    @Getter
    @Setter
    private String walletString;

    @Getter
    @Setter
    private String userBankNo;

    @Getter
    @Setter
    private String bankCode;

    @Getter
    @Setter
    private String bankName;

    @Getter
    @Setter
    private String capitalMode;

    @Getter
    @Setter
    private String fundType;

    // 前端基金类型
    @Getter
    @Setter
    private int appFundType;

    /**
     * 分红文案
     */
    @Getter
    @Setter
    private String dividends;

    // 分红方式
    @Getter
    @Setter
    private String autoBuy;
}
